package com.wgts.wgts.mvp.view.activity.shopkeeper;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.wgts.wgts.R;
import com.wgts.wgts.netmodle.resp.OperatingDataEntity;
import com.wgts.wgts.tools.MoHuGlide;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OperatingProductAdapter extends RecyclerView.Adapter<OperatingProductAdapter.ProductViewHolder> {



    private List<OperatingDataEntity.Product> products;

    private Context context;

    public OperatingProductAdapter(List<OperatingDataEntity.Product> products, Context context) {
        this.products = products;
        this.context = context;
    }

    @NonNull
    @Override
    public ProductViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new ProductViewHolder(LayoutInflater.from(context).inflate(R.layout.my_order_image_item, viewGroup, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ProductViewHolder productViewHolder, int i) {
        MoHuGlide.getInstance().glideImgsFormList(productViewHolder.myOrderImage, products.get(i).productSmallImage, context);
    }

    @Override
    public int getItemCount() {
        return products.size();
    }

    public class ProductViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.my_order_image)
        ImageView myOrderImage;
        public ProductViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
